package com.iyundao.io.mapper;

import com.iyundao.io.model.Gift;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface GiftMapper {
    @Insert({
        "insert into gift (id, giftname, ",
        "giftnum, giftintegral, ",
        "giftdetails, giftimg, ",
        "gifttime, giftflag, ",
        "organizationid)",
        "values (#{id,jdbcType=INTEGER}, #{giftname,jdbcType=VARCHAR}, ",
        "#{giftnum,jdbcType=VARCHAR}, #{giftintegral,jdbcType=INTEGER}, ",
        "#{giftdetails,jdbcType=VARCHAR}, #{giftimg,jdbcType=VARCHAR}, ",
        "#{gifttime,jdbcType=TIMESTAMP}, #{giftflag,jdbcType=SMALLINT}, ",
        "#{organizationid,jdbcType=VARCHAR})"
    })
    int insert(Gift record);

    @InsertProvider(type= GiftSqlProvider.class, method="insertSelective")
    int insertSelective(Gift record);

    @Select("select * from gift where id=#{id,jdbcType=INTEGER}")
    Gift selectById(Integer id);

    @Update("update gift set giftflag=1 where id=#{id,jdbcType=INTEGER}")
    int updateFlag(Integer id);

    @Select("select * from gift where organizationid=#{organizationid,jdbcType=VARCHAR}")
    List<Gift> selectByOrganizationId(String organizationid);

    @InsertProvider(type= GiftSqlProvider.class, method="updateSelective")
    int updateSelective(Gift record);

}